Model
class is how these changes can be tracked in Weave.
In this tutorial you’ll learn:
- How to use Weave
Model
to track and version your application and its parameters. - How to export, modify and re-use a Weave
Model
already logged.
Using weave.Model
The
weave.Model
class is currently only supported in Python.Model
s means that parameters such as model vendor ids, prompts, temperature, and more are stored and versioned when they change.
To create a Model
in Weave, you need the following:
- a class that inherits from
weave.Model
- type definitions on all class fields
- a typed
invoke
function with the@weave.op()
decorator
invoke
:
.invoke
you can see the trace in Weave now tracks the model parameters as well as the code for the model functions that have been decorated with weave.op()
. You can see the model is also versioned, “v21” in this case, and if you click on the model you can see all of the calls that have used that version of the model

weave.Model
:
- You can use
predict
instead ofinvoke
for the name of the function in your WeaveModel
if you prefer. - If you want other class methods to be tracked by weave they need to be wrapped in
weave.op()
- Parameters starting with an underscore are ignored by weave and won’t be logged
Exporting and re-using a logged weave.Model
Because Weave stores and versions Models that have been invoked, it is possible to export and re-use these models.
Get the Model ref
In the Weave UI you can get the Model ref for a particular version
Using the Model
Once you have the URI of the Model object, you can export and re-use it. Note that the exported model is already initialised and ready to use:

What’s next?
- Follow the Build an Evaluation pipeline tutorial to start iteratively improving your applications.